package kpi.java_training.testing.questions;

import kpi.java_training.testing.education.TypeScore;
import kpi.java_training.testing.services.StringServices;

import java.util.List;

/**
 * Class implements question where answer is string
 */
public class StringQuestion extends Question {
    private List<String> correctAnswers;
    private String answer;
    private String type;
    public StringQuestion(String questionMessage, List<String> correctAnswers, int level) {
        super(questionMessage);
        this.correctAnswers = correctAnswers;

        this.level = level;
        answer = null;
    }


    @Override
    public boolean isCorrect() {
        return correctAnswers.contains(answer);
    }

    @Override
    public void setAnswer(String answer) {
        setOriginalAnswer(answer);
        this.answer = answer;
    }
    @Override
    public void clearAnswer() {
        answer = null;
    }

    @Override
    public String getQuestionSaveData() {
        String str = super.getQuestionSaveData();
        str = StringServices.makeString(str, StringServices.getSaveDataFromStrings(correctAnswers));
        return str;
    }

    @Override
    protected String getQuestionHelp() {
        return "Answer the question.";
    }
    @Override
    protected int getQuestionType() {
        return Question.STRING;
    }
}
